//导入 mongoose
//const { time } = require('@pupbot/core');
const mongoose = require('mongoose');
//创建文档的结构对象
//设置集合中文档的属性以及属性值的类型

const imageSchema = new mongoose.Schema({
  url:  { 
    type: String,
    default: '' 
  }
});
const itemsSchema =  new mongoose.Schema({
  itemUrl:String,
  itemTitle:String,
  orderPrice:Number,
  orderNum:String,
  showPrice:Number,
  orderSKU:String,
  images:[imageSchema]
});
let addtaskSchema = new mongoose.Schema({
  device_id:{ 
    type:mongoose.Schema.Types.ObjectId,
  },
  user_id:{ 
    type:mongoose.Schema.Types.ObjectId,
  },
  orderNumber: { 
    type: String,
    default: '' 
  },
  taskNumber:String,
  shopName:String,
  AliName:String,
  items:[itemsSchema],
  urlType:Boolean,
  chatType:Boolean,
  taskType:String,
  keyWords:[String],
  state: Number,
  creatDate:Date,
  last_time: Date,
  startTime: Date
});

//创建模型对象  对文档操作的封装对象
let addtaskModel = mongoose.model('addtask', addtaskSchema);

//暴露模型对象
module.exports = addtaskModel;
